﻿<%@ Page Title="Like Us" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="LikeUsWebSite._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

    <asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
        <AnonymousTemplate>
        <script>            window.location = "./Welcome.aspx";</script>
        </AnonymousTemplate>
        <LoggedInTemplate> 
        <script  type="text/javascript">
            var howmuch = 0;
            var updating = false;

            function updateMoviesList() {
                howmuch += 5;
                updating = true;
                var behavior = $find('dp2');
                toggleVisibility(document.getElementById('loadingdiv'));
                behavior.add_populated(donePopulating);
                if (behavior) {
                    behavior.populate(howmuch);
                }
            }
            Sys.Application.add_load(function () { updateMoviesList(); });

            function donePopulating() {
                updating = false;
                toggleVisibility(document.getElementById('loadingdiv'));
            }

            function toggleVisibility(me) {
                if (me.style.visibility == "hidden") {
                    me.style.visibility = "visible";
                }
                else {
                    me.style.visibility = "hidden";
                }
            }

            function checkValue(me) {

                me.style.display = "none";
            }

            setInterval(function () {

                var totalHeight, currentScroll, visibleHeight;

                if (document.documentElement.scrollTop)
                { currentScroll = document.documentElement.scrollTop; }
                else
                { currentScroll = document.body.scrollTop; }

                totalHeight = document.body.offsetHeight;
                visibleHeight = document.documentElement.clientHeight;

                if (totalHeight == currentScroll + visibleHeight && !updating) {
                                updateMoviesList();
                            }
                        }
            , 100);

        </script>
        <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
        <h2>Recommended movies:</h2><br />
            <p> Below are movies that are favorits by your lookalike people.
            If you have seen any of these movies, please rate them so that your results will be updated.</p>

            <asp:Panel ID="Panel2" runat="server" CssClass="dynamicPopulate_Normal"/>
            <ajaxToolkit:DynamicPopulateExtender ID="dp2" BehaviorID="dp2" runat="server"  
            TargetControlID="Panel2"  
            ClearContentsDuringUpdate="false"  
            ServiceMethod="GetTopGroupMovies"  
            ServicePath="~/Ajax/services.asmx"
            UpdatingCssClass="dynamicPopulate_Updating"/> 
            <center><div id="loadingdiv" style="position:relative;background-color:#EDEFF4;border:1px solid #D8DFEA;width:100px"><img src="./Images/loading.gif"/></div></center>
        </LoggedInTemplate>
    </asp:LoginView>
</asp:Content>